/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#include "LuaRichEdit.h"

#define CObjPtr ((CRichEditUI*)m_cobj)

namespace DuiLib {

bool LuaRichEdit::IsMultiLine()
{
    return CObjPtr->IsMultiLine();
}

void LuaRichEdit::SetMultiLine(bool bMultiLine)
{
    CObjPtr->SetMultiLine(bMultiLine);
}

bool LuaRichEdit::IsWantTab()
{
    return CObjPtr->IsWantTab();
}

void LuaRichEdit::SetWantTab(bool bWantTab)
{
    CObjPtr->SetWantTab(bWantTab);
}

bool LuaRichEdit::IsWantReturn()
{
    return CObjPtr->IsWantReturn();
}

void LuaRichEdit::SetWantReturn(bool bWantReturn)
{
    CObjPtr->SetWantReturn(bWantReturn);
}

bool LuaRichEdit::IsWantCtrlReturn()
{
    return CObjPtr->IsWantCtrlReturn();
}

void LuaRichEdit::SetWantCtrlReturn(bool bWantCtrlReturn)
{
    CObjPtr->SetWantCtrlReturn(bWantCtrlReturn);
}

bool LuaRichEdit::IsRich()
{
    return CObjPtr->IsRich();
}

void LuaRichEdit::SetRich(bool bRich)
{
    CObjPtr->SetRich(bRich);
}

bool LuaRichEdit::IsReadOnly()
{
    return CObjPtr->IsReadOnly();
}

void LuaRichEdit::SetReadOnly(bool bReadOnly)
{
    CObjPtr->SetReadOnly(bReadOnly);
}

bool LuaRichEdit::GetWordWrap()
{
    return CObjPtr->GetWordWrap();
}

void LuaRichEdit::SetWordWrap(bool bWordWrap)
{
    CObjPtr->SetWordWrap(bWordWrap);
}

int LuaRichEdit::GetFont()
{
    return CObjPtr->GetFont();
}

int LuaRichEdit::SetFont(LuaState *L)
{
    LuaStack args(L);
    if (args[2].IsTable()) {
        LuaObject tab = args[2];
        SDTString name = LuaHelperNS::GetTString(tab.GetByName("name"));
        int nSize = LuaHelperNS::GetInt(tab.GetByName("size"));
        bool bBold = LuaHelperNS::GetBool(tab.GetByName("bold"));
        bool bUnderline = LuaHelperNS::GetBool(tab.GetByName("underline"));
        bool bItalic = LuaHelperNS::GetBool(tab.GetByName("italic"));
        CObjPtr->SetFont(name.c_str(), nSize, bBold, bUnderline, bItalic);
    } else {
        int index = LuaHelperNS::GetInt(args[2]);
        CObjPtr->SetFont(index);
    }
    return 0;
}

void LuaRichEdit::SetEnabled(bool bEnabled)
{
    CObjPtr->SetEnabled(bEnabled);
}

LONG LuaRichEdit::GetWinStyle()
{
    return CObjPtr->GetWinStyle();
}

void LuaRichEdit::SetWinStyle(LONG lStyle)
{
    CObjPtr->SetWinStyle(lStyle);
}

DWORD LuaRichEdit::GetTextColor()
{
    return CObjPtr->GetTextColor();
}

void LuaRichEdit::SetTextColor(DWORD dwTextColor)
{
    CObjPtr->SetTextColor(dwTextColor);
}

int LuaRichEdit::GetLimitText()
{
    return CObjPtr->GetLimitText();
}

void LuaRichEdit::SetLimitText(int iChars)
{
    CObjPtr->SetLimitText(iChars);
}

int LuaRichEdit::GetTextLength(LuaState *L)
{
    LuaStack args(L);
    DWORD dwFlags = LuaHelperNS::GetDWord(args[2]);
    int len = CObjPtr->GetTextLength(dwFlags);
    L->PushInteger(len);
    return 1;
}

int LuaRichEdit::GetText(LuaState *L)
{
    SDTString str = CObjPtr->GetText().GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetText(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetText(str.c_str());
    return 0;
}

bool LuaRichEdit::GetModify()
{
    return CObjPtr->GetModify();
}

void LuaRichEdit::SetModify(bool bModified)
{
    CObjPtr->SetModify(bModified);
}

int LuaRichEdit::GetSel(LuaState *L)
{
    long nStartChar = 0;
    long nEndChar = 0;
    CObjPtr->SetSel(nStartChar, nEndChar);
    L->PushInteger(nStartChar);
    L->PushInteger(nEndChar);
    return 2;
}

int LuaRichEdit::SetSel(long nStartChar, long nEndChar)
{
    return CObjPtr->SetSel(nStartChar, nEndChar);
}

int LuaRichEdit::ReplaceSel(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    bool bCanUndo = LuaHelperNS::GetBool(args[3]);
    CObjPtr->ReplaceSel(str.c_str(), bCanUndo);
    return 0;
}

int LuaRichEdit::ReplaceSelW(LuaState *L)
{
    LuaStack args(L);
    if (args[2].IsWString()) {
        LPCWSTR str = (LPCWSTR)args[2].GetWString();
        bool bCanUndo = LuaHelperNS::GetBool(args[3]);
        CObjPtr->ReplaceSelW(str, bCanUndo);
    }
    return 0;
}

int LuaRichEdit::GetSelText(LuaState *L)
{
    SDTString str = CObjPtr->GetSelText().GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetSelAll()
{
    return CObjPtr->SetSelAll();
}

int LuaRichEdit::SetSelNone()
{
    return CObjPtr->SetSelNone();
}

WORD LuaRichEdit::GetSelectionType()
{
    return CObjPtr->GetSelectionType();
}

int LuaRichEdit::GetZoom(LuaState *L)
{
    int nNum, nDen;
    bool bRet = CObjPtr->GetZoom(nNum, nDen);
    L->PushBoolean(bRet);
    L->PushInteger(nNum);
    L->PushInteger(nDen);
    return 3;
}

bool LuaRichEdit::SetZoom(int nNum, int nDen)
{
    return CObjPtr->SetZoom(nNum, nDen);
}

bool LuaRichEdit::SetZoomOff()
{
    return CObjPtr->SetZoomOff();
}

bool LuaRichEdit::GetAutoURLDetect()
{
    return CObjPtr->GetAutoURLDetect();
}

bool LuaRichEdit::SetAutoURLDetect(bool bAutoDetect)
{
    return CObjPtr->SetAutoURLDetect(bAutoDetect);
}

DWORD LuaRichEdit::GetEventMask()
{
    return CObjPtr->GetEventMask();
}

DWORD LuaRichEdit::SetEventMask(DWORD dwEventMask)
{
    return CObjPtr->SetEventMask(dwEventMask);
}

int LuaRichEdit::GetTextRange(LuaState *L)
{
    LuaStack args(L);
    LONG nStartChar = LuaHelperNS::GetLong(args[2]);
    LONG nEndChar = LuaHelperNS::GetLong(args[3]);
    SDTString str = CObjPtr->GetTextRange(nStartChar, nEndChar).GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::HideSelection(LuaState *L)
{
    LuaStack args(L);
    bool bHide = LuaHelperNS::GetBool(args[2], true);
    bool bChangeStyle = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->HideSelection(bHide, bChangeStyle);
    return 0;
}

void LuaRichEdit::ScrollCaret()
{
    CObjPtr->ScrollCaret();
}

int LuaRichEdit::InsertText(LuaState *L)
{
    LuaStack args(L);
    int iRet = 0;
    LONG nInsertAfterChar = LuaHelperNS::GetLong(args[2]);
    SDTString str = LuaHelperNS::GetTString(args[3]);
    bool bCanUndo = LuaHelperNS::GetBool(args[4], false);
    if (!str.empty()) {
        iRet = CObjPtr->InsertText(nInsertAfterChar, str.c_str(), bCanUndo);
    }
    L->PushInteger(iRet);
    return 1;
}

int LuaRichEdit::AppendText(LuaState *L)
{
    LuaStack args(L);
    int iRet = 0;
    SDTString str = LuaHelperNS::GetTString(args[2]);
    bool bCanUndo = LuaHelperNS::GetBool(args[3], false);
    if (!str.empty()) {
        iRet = CObjPtr->AppendText(str.c_str(), bCanUndo);
    }
    L->PushInteger(iRet);
    return 1;
}

bool LuaRichEdit::CanUndo()
{
    return CObjPtr->CanUndo();
}

bool LuaRichEdit::CanRedo()
{
    return CObjPtr->CanRedo();
}

bool LuaRichEdit::CanPaste()
{
    return CObjPtr->CanPaste();
}

bool LuaRichEdit::Redo()
{
    return CObjPtr->Redo();
}

bool LuaRichEdit::Undo()
{
    return CObjPtr->Undo();
}

void LuaRichEdit::Clear()
{
    CObjPtr->Clear();
}

void LuaRichEdit::Copy()
{
    CObjPtr->Copy();
}

void LuaRichEdit::Cut()
{
    CObjPtr->Cut();
}

void LuaRichEdit::Paste()
{
    CObjPtr->Paste();
}

int LuaRichEdit::GetLineCount()
{
    return CObjPtr->GetLineCount();
}

int LuaRichEdit::GetLine(LuaState *L)
{
    LuaStack args(L);
    int nIndex = LuaHelperNS::GetInt(args[2], -1);
    int nMaxLength = LuaHelperNS::GetInt(args[3], -1);
    if (nIndex < 0 || nMaxLength < 0) {
        L->PushNil();
        return 1;
    }
    SDTString str = CObjPtr->GetLine(nIndex, nMaxLength).GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::LineIndex(LuaState *L)
{
    LuaStack args(L);
    int nLine = LuaHelperNS::GetInt(args[2], -1);
    int iRet = CObjPtr->LineIndex(nLine);
    L->PushInteger(iRet);
    return 1;
}

int LuaRichEdit::LineLength(LuaState *L)
{
    LuaStack args(L);
    int nLine = LuaHelperNS::GetInt(args[2], -1);
    int iRet = CObjPtr->LineLength(nLine);
    L->PushInteger(iRet);
    return 1;
}

int LuaRichEdit::LineScroll(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    int nLine = LuaHelperNS::GetInt(args[2], -1);
    int nChars = LuaHelperNS::GetInt(args[2], 0);
    if (nLine < 0) {
        bRet = CObjPtr->LineScroll(nLine, nChars);
    }
    L->PushBoolean(bRet);
    return 1;
}

long LuaRichEdit::LineFromChar(long nIndex)
{
    return CObjPtr->LineFromChar(nIndex);
}

int LuaRichEdit::PosFromChar(LuaState *L)
{
    LuaStack args(L);
    UINT nChar = LuaHelperNS::GetUInt(args[2]);
    CDuiPoint pt = CObjPtr->PosFromChar(nChar);
    L->PushInteger(pt.x);
    L->PushInteger(pt.y);
    return 2;
}

int LuaRichEdit::CharFromPos(LuaState *L)
{
    LuaStack args(L);
    POINT pt = LuaHelperNS::GetPoint(args[2]);
    int iRet = CObjPtr->CharFromPos(CDuiPoint(pt));
    L->PushInteger(iRet);
    return 1;
}

UINT LuaRichEdit::SetUndoLimit(UINT nLimit)
{
    return CObjPtr->SetUndoLimit(nLimit);
}

void LuaRichEdit::SetAccumulateDBCMode(bool bDBCMode)
{
    CObjPtr->SetAccumulateDBCMode(bDBCMode);
}

bool LuaRichEdit::IsAccumulateDBCMode()
{
    return CObjPtr->IsAccumulateDBCMode();
}

bool LuaRichEdit::SetDropAcceptFile(bool bAccept)
{
    return CObjPtr->SetDropAcceptFile(bAccept);
}

int LuaRichEdit::SetScrollPos(LuaState *L)
{
    LuaStack args(L);
    SIZE sz = LuaHelperNS::GetSize(args[2]);
    bool bMsg = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetScrollPos(sz, bMsg);
    return 0;
}

void LuaRichEdit::LineUp()
{
    CObjPtr->LineUp();
}

void LuaRichEdit::LineDown()
{
    CObjPtr->LineDown();
}

void LuaRichEdit::PageUp()
{
    CObjPtr->PageUp();
}

void LuaRichEdit::PageDown()
{
    CObjPtr->PageDown();
}

void LuaRichEdit::HomeUp()
{
    CObjPtr->HomeUp();
}

void LuaRichEdit::EndDown()
{
    CObjPtr->EndDown();
}

void LuaRichEdit::LineLeft()
{
    CObjPtr->LineLeft();
}

void LuaRichEdit::LineRight()
{
    CObjPtr->LineRight();
}

void LuaRichEdit::PageLeft()
{
    CObjPtr->PageLeft();
}

void LuaRichEdit::PageRight()
{
    CObjPtr->PageRight();
}

void LuaRichEdit::HomeLeft()
{
    CObjPtr->HomeLeft();
}

void LuaRichEdit::EndRight()
{
    CObjPtr->EndRight();
}

int LuaRichEdit::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaRichEdit::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetPos(rc, bNeedInvalidate);
    return 0;
}

int LuaRichEdit::Move(LuaState *L)
{
    LuaStack args(L);
    SIZE sz = LuaHelperNS::GetSize(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->Move(sz, bNeedInvalidate);
    return 0;
}


int LuaRichEdit::GetNormalImage(LuaState *L)
{
    SDTString str = CObjPtr->GetNormalImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetNormalImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetNormalImage(str.c_str());
    return 0;
}

int LuaRichEdit::GetHotImage(LuaState *L)
{
    SDTString str = CObjPtr->GetHotImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetHotImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetHotImage(str.c_str());
    return 0;
}

int LuaRichEdit::GetFocusedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetFocusedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetFocusedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetFocusedImage(str.c_str());
    return 0;
}

int LuaRichEdit::GetDisabledImage(LuaState *L)
{
    SDTString str = CObjPtr->GetDisabledImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetDisabledImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetDisabledImage(str.c_str());
    return 0;
}

int LuaRichEdit::GetTextPadding(LuaState *L)
{
    RECT rc = CObjPtr->GetTextPadding();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

int LuaRichEdit::SetTextPadding(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetTextPadding(rc);
    return 0;
}

int LuaRichEdit::SetTipValue(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetTipValue(str.c_str());
    return 0;
}

int LuaRichEdit::GetTipValue(LuaState *L)
{
    SDTString str = CObjPtr->GetTipValue();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaRichEdit::SetTipValueColor(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetTipValueColor(str.c_str());
    return 0;
}

DWORD LuaRichEdit::GetTipValueColor()
{
    return CObjPtr->GetTipValueColor();
}

void LuaRichEdit::SetTipValueAlign(UINT uAlign)
{
    CObjPtr->SetTipValueAlign(uAlign);
}

UINT LuaRichEdit::GetTipValueAlign()
{
    return CObjPtr->GetTipValueAlign();
}

SDLUA_BEGIN_REGISTER(LuaRichEdit, RichEdit, Container)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsMultiLine, IsMultiLine)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetMultiLine, SetMultiLine)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsWantTab, IsWantTab)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetWantTab, SetWantTab)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsWantReturn, IsWantReturn)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetWantReturn, SetWantReturn)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsWantCtrlReturn, IsWantCtrlReturn)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetWantCtrlReturn, SetWantCtrlReturn)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsRich, IsRich)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetRich, SetRich)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsReadOnly, IsReadOnly)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetReadOnly, SetReadOnly)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetWordWrap, GetWordWrap)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetWordWrap, SetWordWrap)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetFont, GetFont)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetFont, SetFont)

    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetEnabled, SetEnabled)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetWinStyle, GetWinStyle)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetWinStyle, SetWinStyle)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetTextColor, GetTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetTextColor, SetTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetLimitText, GetLimitText)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetLimitText, SetLimitText)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetTextLength, GetTextLength)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetText, GetText)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetText, SetText)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetModify, GetModify)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetModify, SetModify)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetSel, GetSel)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetSel, SetSel)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, ReplaceSel, ReplaceSel)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, ReplaceSelW, ReplaceSelW)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetSelText, GetSelText)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetSelAll, SetSelAll)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetSelNone, SetSelNone)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetSelectionType, GetSelectionType)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetZoom, GetZoom)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetZoom, SetZoom)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetZoomOff, SetZoomOff)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetAutoURLDetect, GetAutoURLDetect)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetAutoURLDetect, SetAutoURLDetect)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetEventMask, GetEventMask)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetEventMask, SetEventMask)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetTextRange, GetTextRange)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, HideSelection, HideSelection)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, ScrollCaret, ScrollCaret)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, InsertText, InsertText)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, AppendText, AppendText)
    
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, CanUndo, CanUndo)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, CanRedo, CanRedo)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, CanPaste, CanPaste)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, Redo, Redo)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, Undo, Undo)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, Clear, Clear)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, Copy, Copy)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, Cut, Cut)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, Paste, Paste)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetLineCount, GetLineCount)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetLine, GetLine)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, LineIndex, LineIndex)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, LineLength, LineLength)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, LineScroll, LineScroll)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, LineFromChar, LineFromChar)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, PosFromChar, PosFromChar)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, CharFromPos, CharFromPos)

    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetUndoLimit, SetUndoLimit)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetAccumulateDBCMode, SetAccumulateDBCMode)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, IsAccumulateDBCMode, IsAccumulateDBCMode)
   
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetDropAcceptFile, SetDropAcceptFile)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetScrollPos, SetScrollPos)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, LineUp, LineUp)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, LineDown, LineDown)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, PageUp, PageUp)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, PageDown, PageDown)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, HomeUp, HomeUp)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, EndDown, EndDown)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, LineLeft, LineLeft)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, LineRight, LineRight)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, PageLeft, PageLeft)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, PageRight, PageRight)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, HomeLeft, HomeLeft)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, EndRight, EndRight)
    
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, EstimateSize, EstimateSize)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetPos, SetPos)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, Move, Move)

    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetNormalImage, GetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetNormalImage, SetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetHotImage, GetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetHotImage, SetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetFocusedImage, GetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetFocusedImage, SetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetDisabledImage, GetDisabledImage)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetDisabledImage, SetDisabledImage)

    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetTextPadding, GetTextPadding)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetTextPadding, SetTextPadding)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetTipValue, SetTipValue)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, GetTipValue, GetTipValue)
    SDLUA_REGISTER_FUN_LUA(LuaRichEdit, SetTipValueColor, SetTipValueColor)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetTipValueColor, GetTipValueColor)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, SetTipValueAlign, SetTipValueAlign)
    SDLUA_REGISTER_FUN_CPP(LuaRichEdit, GetTipValueAlign, GetTipValueAlign)
    
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaRichEdit, RichEdit)
SDLUA_END_UNREGISTER(RichEdit)

}

#undef CObjPtr